<template>
  <div>
    <div class="top-operate-default">
      <div class="search-item">
        <label>搜索店主：</label>
        <el-input style="width: 220px;" v-model="searchListQuery.nickname" placeholder="请输入店主昵称/姓名/手机号"></el-input>
        <el-button-group class="mar-l-20">
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button plain="" @click="resetSearch">重置</el-button>
        </el-button-group>
      </div>
    </div>
    <!-- 内容列表 -->
    <div class="table-container mar-t-20">
      <el-table ref="multipleTable" :data="entityList" v-loading="listLoading" element-loading-text="加载中" style="width: 100%" header-cell-class-name="default-header"
          row-class-name="default-row" >
        <el-table-column label="店主信息" min-width="300px">
          <template slot-scope="scope">
            <div class="flex v-align-c cursor-p">
              <label>
                <img :src="scope.row.avatar" class="user-avatar-r" v-if="scope.row.avatar">
                <img v-else src="https://veekrayimg.joinsun.vip/head-portrait.png" class="user-avatar-r" alt="">
              </label>
              <div class="font-14 pad-l-10 height-59 line-h-14">
                <div><span class="font-color-9">昵称：</span>{{scope.row.nickname}}</div>
                <div><span class="font-color-9">姓名：</span>{{scope.row.realName}}</div>
                <div><span class="font-color-9">手机：</span>{{scope.row.phone}}</div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column min-width="200px">
          <template slot="header" slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="直接分享+海报分享+其他途径进入直播购物分享页的观众人数" placement="top-start">
              <span>合计获客</span>
            </el-tooltip>
          </template>
          <template slot-scope="scope">
            <span>合计: {{ scope.row.countNum }}</span>
            <!-- <br/><span>成交订单数: {{ scope.row.shareOrderNum + scope.row.posterOrderNum }}</span>
            <br/><span>成交总金额: {{ scope.row.shareOrderPrice + scope.row.posterOrderPrice }}</span> -->
          </template>
        </el-table-column>
        <el-table-column min-width="200px">
          <template slot="header" slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="通过直接分享直播间进入直播购物分享页的观众人数" placement="top-start">
              <span>直接分享</span>
            </el-tooltip>
          </template>
          <template slot-scope="scope">
            <div class="line-h-14">
              <div>合计: {{ scope.row.liveShareNum }}</div>
              <div class="font-12"><span class="font-color-9">成交订单数：</span><span style="color: #409eff;">{{ scope.row.shareOrderNum }}</span></div>
              <div class="font-12"><span class="font-color-9">成交总金额：</span>{{ scope.row.shareOrderPrice }}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column min-width="200px">
          <template slot="header" slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="通过扫码直播海报二维码进入直播购物分享页的观众人数" placement="top-start">
              <span>海报分享</span>
            </el-tooltip>
          </template>
          <template slot-scope="scope">
            <div class="line-h-14">
              <div>合计: {{ scope.row.posterShareNum }}</div>
              <div class="font-12"><span class="font-color-9">成交订单数：</span><span style="color: #409eff;">{{ scope.row.posterOrderNum }}</span></div>
              <div class="font-12"><span class="font-color-9">成交总金额：</span>{{ scope.row.posterOrderPrice }}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column min-width="200px">
          <template slot="header" slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="通过自然搜索进入店铺首页等途径进入直播间人数" placement="top-start">
              <span>其它途径</span>
            </el-tooltip>
          </template>
          <template slot-scope="scope">
            <div class="line-h-14">
              <div>合计: {{ scope.row.otherShareNum }}</div>
              <div class="font-12"><span class="font-color-9">成交订单数：</span><span style="color: #409eff;">{{ scope.row.otherOrderNum }}</span></div>
              <div class="font-12"><span class="font-color-9">成交总金额：</span>{{ scope.row.otherOrderPrice }}</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 列表分页 -->
    <div class="pagination">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page="searchListQuery.currentPage"
                     :page-sizes="[10, 20, 50, 100]" :page-size="searchListQuery.size"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<style lang="less" scoped>
  .time-line{
    width: 20%;
    float: left;
    .time-box{
      position: fixed;
      width: 19%;
      right: 0;
      top: 95px;
    }
  }
  .user-avatar-r{
    width: 59px;
    height: 59px;
    display: block;
    border-radius: 50px;
  }
  .detila-div-80{
    float: left;
    width: 80%;
  }

  .div-styls{
    margin-top: 30px;
    margin-bottom: 20px;
  }
  .el-tabs__item{
    font-size: 20px;
  }
  .line-h-14{
    line-height: 1.4;
  }
</style>

<script>
  import { pagingRaking } from '@/api/user/liveRoom'
  export default {
    data() {
      return {
        searchListQuery: {
          currentPage: 1,
          size: 10,
          nickname: ''
        },
        total: 0,
        entityList: [],
        listLoading: false
      }
    },
    // 初始化页面
    created() {
      this.handleSearch()
    },
    mounted() {
    },
    methods: {
      // 更改当前页数
      handleCurrentChange(val) {
        this.searchListQuery.currentPage = val
        this.handleSearch()
      },
      // 更改当前页面大小
      handleSizeChange(val) {
        this.searchListQuery.size = val
        this.handleSearch()
      },
      handleSearch() {
        this.searchListQuery.enterpriseId = this.getEnterpriseId()
        pagingRaking(this.searchListQuery).then(response => {
          if (response.isError) return
          this.entityList = response.data.records
          this.total = response.data.total
          this.dict = response.data.dict
        })
      },
      resetSearch() {
        this.searchListQuery.currentPage = 1
        this.searchListQuery.nickname = ''
        this.handleSearch()
      }
    }
  }
</script>
